
<template>
    <div class="child">
        <h4>suspense的使用</h4>
        <h4>我是Child组件</h4>
        {{sum}}
    </div>
</template>

<script>
    import {ref} from 'vue'
    export default {
        name: "Suspense",
        // 配合suspense 可以做异步延时组件加载
        async setup(){
            let sum = ref(0)
            let p = new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    resolve({sum})
                },3000)
            })
            return await p
        }
    }
</script>

<style>
    .child{
        background-color: skyblue;
    }
</style>